﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Database db = DatabaseFactory.CreateDatabase("MRPSqlServer");
        //string sSQL = "Select Title,Imgfile,DisplayString,URLString,NoRecorderMsg,SQLString from MRP_QuickLink where groupID=2";
        //DataSet ds = db.ExecuteDataSet(CommandType.Text, sSQL);
        //DataList1.DataSource = ds.Tables[0].DefaultView;
        //DataList1.DataBind();
    }
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        Database db = DatabaseFactory.CreateDatabase("MRPSqlServer");

        using (IDataReader reader = db.ExecuteReader(CommandType.Text,
            string.Format("Select ID from dbo.EVOL_User where Login='{0}'", Login1.UserName)))
        {
            if (reader.Read())
            {
                Session["EVOLUserID"] = Int32.Parse(reader[0].ToString());
            }
            else
            {
                MRPUtility.WriteLog(string.Format("系统出现严重问题：该用户在MRP系统中注册不完全（EVO_User表中没有记录）。", Login1.UserName, DateTime.Now), "Error");
            }
        }

        MRPUtility.WriteLog(string.Format("{0}在{1:d} {1:t}登录了本系统。", Login1.UserName, DateTime.Now), "Security");
    }
}
